﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace Sdari.Example.Models
{
    public static class ExampleDbModelExtensions
    {
        /// <summary>
        /// 写入Model的Extension，防止直接创建DbContext
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddExampleDbContext(this IServiceCollection services) => services
            .AddDbContext<IExampleDbContext, ExampleDbContext>(op => op.UseSqlServer("Name=ConnectionStrings:Example").UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking));

    }
}
